///\todo upgrade

//////////////////////////////////////////////////////////////////////////////////
//                                                                              //
//  This file is part of the buola project (https://code.google.com/p/buola/).  //
//                                                                              //
//  Copyright(c) 2007-2012 Xavi Gratal                                          //
//  gratal AT gmail DOT com                                                     //
//                                                                              //
//  Buola is free software: you can redistribute it and/or modify               //
//  it under the terms of the GNU General Public License as published by        //
//  the Free Software Foundation, either version 3 of the License, or           //
//  (at your option) any later version.                                         //
//                                                                              //
//  Buola is distributed in the hope that it will be useful,                    //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of              //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               //
//  GNU General Public License for more details.                                //
//                                                                              //
//  You should have received a copy of the GNU General Public License           //
//  along with buola.  If not, see <http://www.gnu.org/licenses/>.              //
//                                                                              //
//////////////////////////////////////////////////////////////////////////////////

#ifndef _BUOLA_IMAGE_ALGORITHM_FILTER_H_
#define _BUOLA_IMAGE_ALGORITHM_FILTER_H_

#include <buola/image/algorithm/detail/opencv.h>

namespace buola { namespace img {

//! \name filters and color conversion
//@{

template<typename tFormat>
inline void blur(const CView<tFormat> &pSrc,const CMView<tFormat> &pDst,const CSize_i &pKernelSize=CSize_i(3,3))
{
    cv::blur(mat_wrap(pSrc),mat_wrap(pDst),cv::Size(pKernelSize.x,pKernelSize.y));
}

template<typename tFormat>
inline void blur(const CMView<tFormat> &pImage,const CSize_i &pKernelSize=CSize_i(3,3))
{
    const auto &lWrapper=mat_wrap(pImage);

    cv::blur(lWrapper,lWrapper,cv::Size(pKernelSize.x,pKernelSize.y));
}

template<typename tFormat>
inline void gaussian_blur(const CView<tFormat> &pSrc,const CMView<tFormat> &pDst,
                          const CSize_i &pKernelSize=CSize_i(3,3))
{
    cv::GaussianBlur(mat_wrap(pSrc),mat_wrap(pDst),cv::Size(pKernelSize.x,pKernelSize.y),0);
}

template<typename tFormat>
inline void gaussian_blur(const CMView<tFormat> &pImage,const CSize_i &pKernelSize=CSize_i(3,3))
{
    const auto &lWrapper=mat_wrap(pImage);

    cv::GaussianBlur(lWrapper,lWrapper,cv::Size(pKernelSize.x,pKernelSize.y),0);
}

template<typename tFormat>
inline void bilateral_filter(const CView<tFormat> &pSrc,const CMView<tFormat> &pDst,int d, double pSigmaColor)
{
    cv::bilateralFilter(mat_wrap(pSrc),mat_wrap(pDst),d,pSigmaColor,d);
}

/*
template<typename tFormat>
inline void filter_2d(const CView<tFormat> &pSrc,const CMView<tFormat> &pDst,CvMat *pFilter)
{
    cvFilter2D(mat_wrap(pSrc),mat_wrap(pDst),pFilter);
}
*/
template<typename tF1,typename tF2>
inline void convert_scale(const CView<tF1> &pSrc,const CMView<tF2> &pDst,double pScale=1.0,double pShift=0.0)
{
    mat_wrap(pSrc).convertTo(mat_wrap(pDst),MFormatToCVType<tF2>::mMatType,pScale,pShift);
}

void gabor_filter(const CView_gray32f &pSrc,const CMView_gray32f &im_0,const CMView_gray32f &im_45,
                                            const CMView_gray32f &im_90,const CMView_gray32f &im_135);

//@}
    
/*namespace image*/ } /*namespace buola*/ }

#endif
